<?php
/* Code for creating options page */
include(dirname(__FILE__).'/includes/themetoolkit.php');

themetoolkit(
	'mytheme',

	array(
	'featuredCat'		=> 'Featured Posts Category ## Name of the category you would set as featured.',
	'separator1' => '{separator}',
	'featuredNum'		=> 'Number of Featured posts ## How many of posts to display.',
	'separator2' => '{separator}',
	'imageThumb'		=> 'Thumbnail image ## You can use Custom fields to add images for each Post, add the custom field name here',
	'separator3' => '{separator}',
	'sideBlockAds'		=> '125px ads Code {textarea|10|80} ## In the form<br />&lt;li&gt;&lt;a href=&quot;<strong>Link URI</strong>&quot;&gt;&lt;img src=&quot;<strong>Image URI</strong>&quot; /&gt;&lt;/a&gt;&lt;/li&gt;',
	'separator4' => '{separator}',
	'sideAds'		=> 'SideBar Adsense {textarea|10|80} ## Your Sidebar Adsense Code',
	'separator5' => '{separator}',
	'secAds'		=> 'Adsense Code2 {textarea|10|80} ## Shows right after featured posts',

	),
	__FILE__	 
	
);
/* default values upon theme install */
if (!$mytheme->is_installed()) {
   $set_defaults['sideBlockAds'] = '<li><a href="https://www.freshbooks.com/?ref=6cc7a4d9129558-1"><img class="adImage" src="http://www.articled.info/images/freshbook.png" alt="Fresh Books" /></a></li>
   <li><a href="http://graphicriver.net?ref=thebookish"><img src="http://www.articled.info/images/graphicriver.jpg" alt="Graphic River" /></a></li>
   <li><a href="http://themeforest.net?ref=thebookish"><img src="http://www.articled.info/images/themeforest.jpg" alt="Theme Forest" /></a></li>
   <li><a href="http://www.woothemes.com/amember/go.php?r=8681&amp;amp;i=b1"><img src="http://www.articled.info/images/wootheme.gif" alt="Woo Themes" /></a></li>
   ';
   $set_defaults['sideAds'] = '<script type="text/javascript"><!--
google_ad_client = "pub-3877068456410159";
/* 300x250, created 6/14/09 */
google_ad_slot = "6704201756";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
   $set_defaults['secAds'] = '<script type="text/javascript"><!--
google_ad_client = "pub-3877068456410159";
/* 468x15, created 6/15/09 */
google_ad_slot = "1771269949";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
   $result = $mytheme->store_options($set_defaults);
}

/* Define widgetized Sidebar */
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar',
     'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));

/* Remove wp_widget_recent_comments_style */
function remove_wp_widget_recent_comments_style() {
   if ( has_filter('wp_head', 'wp_widget_recent_comments_style') ) {
      remove_filter('wp_head', 'wp_widget_recent_comments_style' );
   }
}
add_filter( 'wp_head', 'remove_wp_widget_recent_comments_style', 1 );

/* Simple Recent comments code */
function src_simple_recent_comments($src_count=7, $src_length=60, $pre_HTML='<li><h2>Recent Comments</h2>', $post_HTML='</li>') {
	global $wpdb;

	$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, 
			SUBSTRING(comment_content,1,$src_length) AS com_excerpt 
		FROM $wpdb->comments 
		LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) 
		WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' 
		ORDER BY comment_date_gmt DESC 
		LIMIT $src_count";
	$comments = $wpdb->get_results($sql);

	$output = $pre_HTML;
	$output .= "\n<ul>";
	foreach ($comments as $comment) {
		$output .= "\n\t<li><a href=\"" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID  . "\" title=\"on " . $comment->post_title . "\">" . "<span>" . $comment->comment_author . "</span> : " . strip_tags($comment->com_excerpt) . "..." . "</a></li>";
	}
	$output .= "\n</ul>";
	$output .= $post_HTML;
	
	echo $output;

}
?>
